//
//  DWHTTPManager.h
//  GMNBase
//
//  Created by DarkWorld on 2019/11/28.
//  Copyright © 2019 Mengnan Gong. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN



#pragma mark - sbds-social--------------------社交模块
#pragma mark - sbds-kafka-consumer------------kafka消息消费模块
#pragma mark - sbds-payment-------------------支付模块
#pragma mark - sbds-seller--------------------商家模块
#pragma mark - sbds-shop----------------------商铺模块
#pragma mark - sbds-goods---------------------商品模块
#pragma mark - sbds-order---------------------订单模块
/**
 网络状态
 @code ///未知网络
 MYNetWorkStatusUnknown          = -1,
 ///无法联网
 MYNetWorkStatusNotReachable          = 0,
 ///手机流量
 MYNetWorkStatusReachableViaWWAN          = 1,
 ///wifi
 MYNetWorkStatusReachableViaWiFi          = 2,
 @endcode
 */
typedef NS_ENUM(NSInteger, MYNetWorkStatus) {
    ///未知网络
    MYNetWorkStatusUnknown          = -1,
    ///无法联网
    MYNetWorkStatusNotReachable          = 0,
    ///手机流量
    MYNetWorkStatusReachableViaWWAN          = 1,
    ///wifi
    MYNetWorkStatusReachableViaWiFi          = 2,
};
///服务模块类型
typedef NS_ENUM(NSUInteger, MYServiceModuleType) {
    ///会员模块
    MYServiceModule_Member = 0,
    ///社交模块 social
    MYServiceModule_social,
    ///kafka消息消费模块
    MYServiceModule_kafka_consumer,
    ///支付模块
    MYServiceModule_payment,
    ///商家模块
    MYServiceModule_seller,
    ///商铺模块
    MYServiceModule_shop,
    ///商品模块
    MYServiceModule_goods,
    ///订单模块
    MYServiceModule_order,
    ///直播模块
    MYServiceModule_live,
    ///工具类模块
    MYServiceModule_tool,
    ///阿里短视频
    MYServiceModule_AliVideo,
    ///阿里短视频
    MYServiceModule_VideoV3,
    ///普通的模块，没有baseurl
    MYServiceModule_normal,


};

@interface DWHTTPManager : NSObject


/**
 *  网络状态检测
 *  -1:位置网络 0:网络不可用 1:2g-4g 2:wifi
 */
+ (void)monitoringNetworkState:(void (^)(MYNetWorkStatus status))block;
#pragma mark 普通一般的网络请求
/**
 封装AFN 请求  请求使用jsonbody

 @param urlString 请求链接
 @param parameters 请求参数
 @param requestType 请求类型 get post
 @param MYServiceModuleType 服务模块类型
 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)postJsonAFNWithUrl:(NSString *)urlString
               parameters:(id)parameters
              requestType:(NSString *)requestType
   MYServiceModuleType:(MYServiceModuleType)MYServiceModuleType
         successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
         failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;

/**
 封装AFN POST请求

 @param urlString 请求链接
 @param parameters 请求参数
 @param MYServiceModuleType 服务模块类型
 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)postAFNWithUrl:(NSString *)urlString
            parameters:(id)parameters
   MYServiceModuleType:(MYServiceModuleType)MYServiceModuleType
         successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
         failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;

/**
 封装AFN GET请求
 
 @param urlString 请求链接
 @param parameters 请求参数
 @param MYServiceModuleType 服务模块类型
 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)getAFNWithUrl:(NSString *)urlString
           parameters:(id)parameters
  MYServiceModuleType:(MYServiceModuleType)MYServiceModuleType
        successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
        failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;

/**
 封装AFN DELETE请求
 
 @param urlString 请求链接
 @param parameters 请求参数
 @param MYServiceModuleType 服务模块类型
 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)deleteAFNWithUrl:(NSString *)urlString
              parameters:(id)parameters
     MYServiceModuleType:(MYServiceModuleType)MYServiceModuleType
           successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
           failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;
/**
 封装AFN PUT请求
 
 @param urlString 请求链接
 @param parameters 请求参数
 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)putAFNWithUrl:(NSString *)urlString
            parameters:(id)parameters
MYServiceModuleType:(MYServiceModuleType)MYServiceModuleType
         successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
        failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;

/**
 *  单文件上传
 *
 *  @param urlString      url地址
 *  @param params         params参数
 *  @param mimeType         mimeType参数
 *

 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)requestDataWithURL:(NSString *)urlString
                withParams:(NSMutableDictionary *)params
                  withData:(NSData *)fileData
              withDataName:(NSString *)dataName
              withFileName:(NSString *)fileName
                  mimeType:(NSString *)mimeType
                  progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress))uploadProgressZSP
             successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
             failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;
/**
 *  多文件上传
 *
 *  @param dataArray      url地址
 *

 @param successHandle 请求成功回调
 @param failureHandle 请求失败回调
 */
+ (void)requestDataWithArray:(NSMutableArray *)dataArray
                  progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress))uploadProgressZSP
             successHandle:(void(^)(NSURLSessionTask *task, id response))successHandle
             failureHandle:(void(^)(NSURLSessionTask *task, NSError *error))failureHandle;
/// 取消所有请求
+ (void)cancelAllRequest;
/// 取消包含关键字地址的请求
/// @param URL 包含对应地址的字符串
+ (void)cancelRequestWithURL:(NSString *)URL;
@end

NS_ASSUME_NONNULL_END
